﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Wys.DataForm.CSharp
{
    public partial class DataBaseVersion : Wys.Control.Vb.AutoAdjustFrom
    {
        public DataBaseVersion()
        {
            InitializeComponent();
        }

        private void DataBaseVersion_Load(object sender, EventArgs e)
        {
            ADODB.Recordset rs = ct.GetTable("select * from XSCVersion");
            if (!rs.EOF)
            {
                this.myEdit1.Text = DateTime.Parse(rs.Fields["DateTime"].Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                rs.Close();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rs); //20100531
            }
        }

        private void btnVersion_Click(object sender, EventArgs e)
        {
            ADODB.Recordset rs = ct.GetTable("select * from XSCVersion");         
            if (!rs.EOF)
            {
                this.myEdit1.Text = DateTime.Parse(rs.Fields["DateTime"].Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                rs.Close();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rs); //20100531
            }

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            ADODB.Recordset rs = ct.GetTable("select * from XSCVersion");
            String strSql = "";
            if (rs.EOF)
            {
                strSql = "insert into XSCVersion(DateTime) values('" + this.dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") + "')";
            }
            else
            {
                strSql = "update  XSCVersion set DateTime='" + this.dateTimePicker1.Value + "'";
            }
            ct.GetUpdateRs(strSql);
            ShowMessageBox("设置成功");
        }
    }
}
